﻿using Cms.Domain;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cms.Tests.Unit.Domain
{

    [TestClass]
    public class MediaCategoryTests
    {

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestContainsMediaFile()
        {
            MediaFile mf1 = new MediaFile { ID = 1 };
            MediaFile mf2 = new MediaFile { ID = 2 };
            Category mc = new Category() { Name = "Cars" };
            mc.MediaFiles.Add(mf1);
            mf1.Categories.Add(mc);
            Assert.IsTrue(mc.ContainsMediaFile(mf1));
            Assert.IsFalse(mc.ContainsMediaFile(mf2));
        }


        [TestMethod]
        public void TestContainsMediaFolder()
        {
            MediaFolder mf1 = new MediaFolder { ID = 1 };
            MediaFolder mf2 = new MediaFolder { ID = 2 };
            Category mc = new Category { ID = 1, Name = "Test"};
            mc.MediaFolders.Add(mf1);
            mf1.Categories.Add(mc);
            Assert.IsTrue(mc.ContainsMediaFolder(mf1));
            Assert.IsFalse(mc.ContainsMediaFolder(mf2));
        }

        [TestMethod]
        public void TestContainsMediaFileViaFolder()
        {
            MediaFile file1 = new MediaFile { ID = 1 };
            MediaFolder folder1 = new MediaFolder { ID = 1 };
            Category mediaCategory = new Category() { ID = 1, Name = "Cars" };
            mediaCategory.MediaFolders.Add(folder1);
            folder1.Categories.Add(mediaCategory);
            file1.Folder = folder1;
            folder1.Files.Add(file1);
            Assert.IsTrue(mediaCategory.ContainsMediaFile(file1));
        }

    }

}
